package com.cta.dao.report.impl;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.cta.dao.impl.BasePersistenceImpl;
import com.cta.dao.report.MasterDataDao;
import com.cta.entity.MasterData;

@Repository("masterDataDao")
public class MasterDataDaoImpl extends BasePersistenceImpl implements MasterDataDao {
	
	public long total() {
		return countObjects("select count(*) from MasterData");
	}

	
	public MasterData lookup(Date fromDate, Date toDate){
		return findSingleObject("select m from MasterData m where m.fromDate <= ?1 and m.toDate >= ?2", fromDate, toDate);
	}
	
	/**
	 * get all table in this range
	 * @param fromDate
	 * @param toDate
	 * @return
	 */
	public List<MasterData> lookups(Date fromDate, Date toDate){
		return getList("select m from MasterData m where m.fromDate <= ?1 and m.toDate >= ?2 order by m.fromDate", fromDate, toDate);
	}

}
